var e = require;
var t = module;
cc.createPrefab = function (e, t) {
    cc.loader.loadRes(e, cc.Prefab, function (e, o) {
        var n = null;
        e ? cc.error("createPrefab " + e) : (n = cc.instantiate(o));
        t && t(e, n);
    });
};
cc.Component.prototype.createNode = function (e, t, o) {
    var n = this;
    cc.log("createNode " + t);
    cc.createPrefab(t, function (t, i) {
        e instanceof cc.Node ? e.addChild(i) : n.node && n.node instanceof cc.Node && n.node.addChild(i, 0);
        o && o(i);
    });
};
cc.Component.prototype.destroyNode = function () {
    this.node && this.node.destroy();
};
cc.Node.prototype.hasComponent = function (e) {
    var t = this;
    Array.isArray(e) || (e = [e]);
    return !!e.find(function (e) {
        return t.getComponent(e);
    });
};
cc.Sprite.prototype.getTextureFilename = function () {
    if (this.spriteFrame) {
        var e = this.spriteFrame._textureFilename,
            t = e.indexOf("resources/");
        return e.substr(t + 10);
    }
    return "";
};
cc.getSpriteFrameByAtlas = function (e, t) {
    var o = cc.path.mainFileName(e),
        n = cc.loader.getRes(o, cc.SpriteAtlas);
    return n ? n.getSpriteFrame(t) : null;
};
cc.createNodeComponent = function (e) {
    return new cc.Node().addComponent(e);
};
cc.Component.prototype.loadScene = function (e, t, o) {
    cc.director.loadScene(t, o);
};
